package com.jcompressor.maven;

/*
 * Copyright (c) 2010, Scott Carnett
 * All rights reserved.
 * 
 * Redistribution and use in source and binary forms, with or without modification, are permitted provided that the
 * following conditions are met:
 * 
 *     * Redistributions of source code must retain the above copyright notice, this list of conditions and the
 *       following disclaimer.
 *     * Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the
 *       following disclaimerin the documentation and/or other materials provided with the distribution.
 *     * Neither the name of jcompressor nor the names of its contributors may be used to endorse or promote products
 *       derived from this software without specific prior written permission.
 * 
 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES,
 * INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
 * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
 * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
 * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
 */

import java.util.List;

import org.apache.maven.plugin.AbstractMojo;
import org.apache.maven.plugin.MojoExecutionException;
import org.apache.maven.plugin.MojoFailureException;

/**
 * @author Scott Carnett
 */
public abstract class AbstractJcompressorMojo extends AbstractMojo {
	
	/**
	 * @parameter expression="${project.name}"
	 */
	private String projectName;
	
	/**
	 * @parameter expression="${project.artifactId}"
	 */
	private String projectArtifactId;
	
	/**
	 * @parameter expression="${project.version}"
	 */
	private String projectVersion;
	
	/**
	 * @parameter expression="${basedir}"
	 */
	private String projectBaseDirectory;
	
	/**
	 * @parameter expression="${project.build.directory}"
	 */
	private String projectBuildDirectory;
	
	/**
	 * @parameter expression="${build.projectConfig}"
	 */
	private String projectConfig;
	
	/**
	 * @parameter
	 */
	private List<String> projects;
	
	/**
	 * @see org.apache.maven.plugin.AbstractMojo#execute()
	 */
	@Override
	public abstract void execute() throws MojoExecutionException,
		MojoFailureException;
	
	/**
	 * Gets the project name
	 * @return String with the project name
	 */
	public String getProjectName() {
		return this.projectName;
	}
	
	/**
	 * Gets the artifact id
	 * @return String with the artifact id
	 */
	public String getProjectArtifactId() {
		return this.projectArtifactId;
	}
	
	/**
	 * Gets the version
	 * @return String with the version
	 */
	public String getProjectVersion() {
		return this.projectVersion;
	}
	
	/**
	 * Gets the base directory
	 * @return String with the base directory
	 */
	public String getProjectBaseDirectory() {
		return this.projectBaseDirectory;
	}
	
	/**
	 * Gets the build directory
	 * @return String with the build directory
	 */
	public String getProjectBuildDirectory() {
		return this.projectBuildDirectory;
	}
	
	/**
	 * Gets the configuration file
	 * @return String with the configuration file
	 */
	public String getProjectConfig() {
		return this.projectConfig;
	}
	
	/**
	 * Gets a list of projects
	 * @return List<String> with the list of projects
	 */
	public List<String> getProjects() {
		return this.projects;
	}
	
	/**
	 * Checks if there are any projects0
	 * @return boolean with the value of true if there are project or false otherwise
	 */
	public boolean hasProjects() {
		if (this.getProjects() == null) {
			return false;
		}
		
		return(this.getProjects().size() > 0);
	}
	
}